package com.zy.ai.tools;

import com.zy.ai.langgraph4j.TenderWorkflow;
import dev.langchain4j.agent.tool.Tool;
import lombok.extern.slf4j.Slf4j;
import org.bsc.langgraph4j.CompiledGraph;
import org.bsc.langgraph4j.GraphRepresentation;
import org.bsc.langgraph4j.prebuilt.MessagesState;
import org.bsc.langgraph4j.state.AgentState;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * @BelongsProject: SmartBidAI
 * @BelongsPackage: com.zy.ai.tools
 * @Author: zhangyan
 * @CreateTime: 2025-09-03  21:30
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Component
public class NodeTools {

    /**
     * 执行工作流并获取每个节点的输出
     */
    @Tool("评标办法处理")
    public Map<String, String> getNodeList() {
        TenderWorkflow tenderWorkflow = new TenderWorkflow();
        CompiledGraph<MessagesState<String>> workflow = tenderWorkflow.createWorkflow();
        Map<String, String> nodeList = new HashMap<>();
        Optional<MessagesState<String>> optionalState = workflow.invoke(Map.of("input", "老师安排的作业太多了"));
        optionalState.ifPresent(state -> {
            nodeList.put("tender_process", "CEHNGGONG");
        });
        System.out.println("结果-----》"+nodeList);
        return nodeList;
    }
}
